home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20031118-20041115
/
000063_fdc@columbia.edu_Mon Dec 15 17:04:30 2003.msg
< prev
next >
Wrap
Lisp/Scheme
|
2004-11-14
|
4KB
|
86 lines
Path: newsmaster.cc.columbia.edu!not-for-mail
From: Frank da Cruz <fdc@columbia.edu>
Newsgroups: comp.protocols.kermit.misc
Subject: EMACS Kermit Mode
Date: 15 Dec 2003 21:57:46 GMT
Organization: Columbia University
Lines: 69
Message-ID: <slrnbtsbiq.p1c.fdc@sesame.cc.columbia.edu>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: sesame.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1071525466 26375 128.59.59.56 (15 Dec 2003 21:57:46 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 15 Dec 2003 21:57:46 GMT
User-Agent: slrn/0.9.7.4 (SunOS)
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:14743
On the recent Slashdot thread, the point was made (several times) that
people who like Kermit tend to be the same people who like EMACS. This
was either a compliment or an insult, depending on the speaker, but
there's definitely some truth to it my case!
Many of us write and edit Kermit scripts in EMACS. But wouldn't it be
so much better if EMACS had a Kermit Mode that automatically indented
appropriately, lined up comments, etc? Now you can have one. The
following instructions should work with all versions of GNU EMACS back
to 19.34. Thanks to Alan Mackenzie (Munich, Germany) for lots of help
with this:
1. Get the latest cc-mode (5.30.8 or later) from:
http://cc-mode.sourceforge.net/release.php
2. Install it for real on your computer or, if you can't do that,
install it in your own file space. Installation is explained in
the README file that comes in the package.
3. If you installed the new cc-mode in your own area, you have to tell
EMACS where to find it. Add the following to your ~/.emacs file:
(setq load-path (cons "~myuserid/cc-mode-5.31" load-path))
(replacing "~myuserid/cc-mode-5.31" with the path of the directory
where you installed the new cc-mode).
Now creating a minimal but serviceable Kermit Mode is easy; just add the
following to your ~/.emacs file:
; Kermit mode
(autoload 'awk-mode "cc-mode" nil t) ; Must load new Awk mode!
(define-derived-mode kermit-mode
awk-mode "Kermit"
"Major Mode for Kermit Scripts"
(auto-fill-mode 1)
(setq fill-column 78)
(setq indent-tabs-mode nil)
(setq brace-else-brace 1)
(setq comment-multi-line nil)
(setq comment-column 40)
(setq comment-start "\# ")
(setq comment-end ""))
Brief explanation: recent releases of EMACS allow you define new major
modes that are derived from existing ones. Awk is a language that is
somewhat similar to Kermit: it uses braces like C, but does not terminate
or separate statements with any particular character (like C does with
semicolon). Instead (in the general case) each statement is on its own
line. We use "#" as the comment character in kermit-mode because using
semicolon confuses the underlying EMACS libraries too much. The old Awk
mode didn't work well enough to base Kermit mode on, the new does.
You might also want to associate Kermit Mode with .ksc files. In that
case add .ksc to your auto-mode-list:
(setq auto-mode-alist (append '(("\\.ksc" . kermit-mode))))
This causes EMACS to switch to Kermit Mode automatically whenever you
visit a file whose name ends in ".ksc".
Kermit Mode not perfect, but it's close. The main problem I've noticed so
far is that SWITCH case labels are not "outdented". Anybody who knows
EMACS LISP better than I do is welcome to make improvements!
- Frank